﻿<template>
    <view>
        <u-navbar title="接龙" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>

        <view class="solitaire-details-bg"></view>
        <view class="solitaire-details-placeholder-body" />

        <!--商家及推荐-->
        <view class="coreshop-margin-20 coreshop-goods-shop-info-view-box">
            <view class="coreshop-shop-view">
                <view class="coreshop-position-absolute">
                    <u-avatar :src="shopLogo" shape="square"></u-avatar>
                </view>
                <view class="coreshop-margin-left-10 coreshop-padding-left-40 coreshop-padding-right-40">
                    <view class="coreshop-margin-bottom-5 coreshop-text-white">{{shopName || ' '}}</view>
                    <view class="coreshop-font-sm u-line-1 coreshop-text-white">{{shareTitle || ' '}}</view>
                </view>
                <u-button type="default" size="mini" :plain="true" @click="doPhoneCall" icon="phone" text="联系商家" color="#272d47"></u-button>
            </view>
        </view>


        <view class="page-box coreshop-margin-top-20" v-if="listData.length > 0">
            <view class="orderList" v-for="(item, itemIndex) in listData" :key="itemIndex">
                <view class="top" @click="goSolitaireDetail(item.id)">
                    <view class="store u-line-2">{{item.title}}</view>
                </view>
                <view class="item">
                    <view class="left">
                        <u--image :showLoading="true" :src="item.thumbnail" width="80px" height="80px" mode="aspectFill"></u--image>
                    </view>
                    <view class="content">
                        <view class="type u-line-2">{{item.description}}</view>
                        <view class="delivery-time">截止时间：{{ $u.timeFormat(item.endTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
                        <view class="coreshop-flex coreshop-align-center coreshop-padding-top-10  coreshop-padding-bottom-5">
                            <view class="coreshop-font-11 coreshop-bg-orange coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.minDeliveryPrice>0">{{item.minDeliveryPrice}}元起送</view>
                            <view class="coreshop-font-11 coreshop-bg-olive coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.startBuyPrice>0">{{item.startBuyPrice}}元起购</view>
                            <!--<view class="coreshop-font-11 coreshop-bg-olive coreshop-padding-2 coreshop-border-radius-4">{{item.ticketNumber}}张券</view>-->
                        </view>
                    </view>
                </view>
                <view class="bottom coreshop-margin-top-10">
                    <view class="more">正在接龙中</view>
                    <view class="coreshop-flex">
                        <view class='coreshop-solitaire-btn' @click="goSolitaireDetail(item.id)">立即接龙</view>
                    </view>
                </view>
            </view>
            <u-loadmore :status="loadStatus"></u-loadmore>
        </view>

        <!-- 无数据时默认显示 -->
        <view class="coreshop-emptybox" v-else>
            <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/order.png'" icon-size="150" text="暂无接龙信息" mode="list"></u-empty>
            <navigator class="coreshop-btn" url="/pages/category/index/index" open-type="switchTab">随便逛逛</navigator>
        </view>
    </view>
</template>

<script>

    export default {

        data() {
            return {
                page: 1,
                limit: 10,
                listData: [],
                loadStatus: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
            }
        },
        onLoad() {
            this.getList();
        },
        computed: {
            shopName() {
                return this.$store.state.config.shopName;
            },
            shareTitle() {
                return this.$store.state.config.shareTitle;
            },
            shopLogo() {
                return this.$store.state.config.shopLogo;
            },
        },
        onReachBottom() {
            if (this.loadStatus === 'loadmore') {
                this.getList();
            }
        },
        methods: {
            //获取列表
            getList() {
                this.loadStatus = 'loading'
                let data = {
                    page: this.page,
                    limit: this.limit,
                }
                this.$u.api.getSolitairePageList(data).then(res => {
                    if (res.status) {
                        let newList = this.listData.concat(res.data);
                        this.listData = newList;
                        if (res.data.count > this.listData.length) {
                            this.page++
                            this.loadStatus = 'loadmore'
                        } else {
                            this.loadStatus = 'nomore'
                        }
                    } else {
                        this.$u.toast(res.msg);
                    }
                });
            }
        }
    }
</script>

<style lang="scss" scoped>
</style>
